﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BookManage.Model
{
    /// <summary>
    /// 实体类Reader
    /// </summary>
    public class Reader
    {
        public Reader() { }
        #region  公有属性
        public int rdID { get; set; }
        public string rdName { get; set; }
        public string rdSex { get; set; }
        public int rdType { get; set; }
        public string rdDept { get; set; }
        public string rdPhone { get; set; }
        public string rdEmail { get; set; }
        public DateTime rdDateReg { get; set; }
        public Byte[] rdPhoto { get; set; }
        public string rdStatus { get; set; }
        public int rdBorrowQty { get; set; }
        public string rdPwd { get; set; }
        public int rdAdminRoles { get; set; }
        #endregion

        public bool IsReaderAdmin()
        {
            return ((rdAdminRoles & 1) > 0);
        }
        public bool IsBookAdmin()
        {
            return ((rdAdminRoles & 2) > 0);
        }
        public bool IsBorrowAdmin()  
        {
            return ((rdAdminRoles & 4) > 0);
        }
        public bool IsSystemAdmin()
        {
            return ((rdAdminRoles & 8) > 0);
        }

        public static string ColumnTitle(string columnName)
        {
            string[,] ColumnsTitle =
            {
                {"rdID","借书证号"},{"rdName","姓名"}, {"rdSex","性别"}, {"rdType","读者类别"},
                {"rdDept","单位" }, {"rdPhone","电话"}, {"rdEmail","电子邮件"}, {"rdDateReg","办证日期"},
                {"rdPhoto","照片"}, {"rdStatus","证件状态"}, {"rdBorrowQty","已借书数量"}, {"rdPwd","密码"},
                {"rdAdminRoles","管理员角色" }
            };
            for (int i = 0; i < ColumnsTitle.Length / 2; i++)
            {
                if (columnName == ColumnsTitle[i, 0])
                    return ColumnsTitle[i, 1];
            }
            return columnName;
        }
    }
}
